(function( window, $ ){

	// 构造marquee	
	var marquee = function(config){
		this.config = $.extend( {}, marquee.config, config);
		this._init();
	};
	
	// 插件默认配置
	marquee.config = {
		step: 28,
		speed: 50,
		delay: 0
	};	
	
	marquee.prototype = {
		_init: function(lh,speed,delay,obj){
			var c = this.config,
	               
				t,p = false, o = c.target; 
	               
				
			o.css('overflow', 'hidden');
			if(c.height) o.css('height', c.height + 'px');

			o.html(o.html()+o.html());
			o.mousemove(function(event) {
				p=true
			});
			o.mouseout(function(event) {
				p=false
			});
			//o.scrollTop = 0;
			function start(){
				t=setInterval(scrolling, c.speed);
				if(!p) 	o.scrollTop(o.scrollTop()+1)				
			};
			function scrolling(){
				if(o.scrollTop%c.step!=0){
					if(!p) 	o.scrollTop(o.scrollTop()+1)
					if(o.scrollTop()>=o[0].scrollHeight/2) o.scrollTop(0);
				}else{
					clearInterval(t);
					setTimeout(start,c.delay);
				}
			};
			setTimeout(start,c.delay);
					
				
			
		}
		
	};
	

	window.marquee = marquee;	



})(window,jQuery);